<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>下午茶订单列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>
<div class="container">

    <div class="comm_content">
        <!-- 查询条件   start -->
        <div class="search-box">
            <div style="position:relative">
                <form class="form-inline" id="search_form" onsubmit="return false;">
                    <table>
                        <tbody>
                        <tr>
                            <td>订单编号：<input type="text" class="form-control input-sm w120" name="bill_code" maxlength="20"></td>
                            <td>会 员 名：<input type="text" class="form-control input-sm w120" name="custID" maxlength="30" value="<!--{$custID|default:''}-->"></td>
                            <td>收 货 人：<input type="text" class="form-control input-sm w120" name="deliver_name" maxlength="20"></td>
                            <td>手机号码：<input type="text" class="form-control input-sm w120" name="deliver_mobile" maxlength="11"></td>
                            <td>支付状态：<select class="form-control input-sm" name="pay_status">
                                    <option value="all">请选择</option>
                                    <!--{foreach from=$global_array.pay_status item=pay_status_name key=pay_status}-->
                                    <option value="<!--{$pay_status}-->"><!--{$pay_status_name}--></option>
                                    <!--{/foreach}-->
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>订单状态：<select class="form-control input-sm" name="bill_status">
                                    <option value="all">请选择</option>
                                    <!--{foreach from=$global_array.backend_bill_status item=bill_status_name key=bill_status}-->
                                        <option value="<!--{$bill_status}-->"><!--{$bill_status_name}--></option>
                                    <!--{/foreach}-->
                                </select>
                            </td>
                            <td>支付方式：<select class="form-control input-sm" name="pay_type">
                                    <option value="">请选择</option>
                                    <option value="1">货到付款</option>
                                    <option value="2">在线支付</option>
                                </select>
                            </td>
                            <td>订单平台：<select class="form-control input-sm" name="billPlatform">
                                    <option value="3">下午茶订单</option>
                                </select>
                            </td>
                            <td>订单渠道：<select class="form-control input-sm" name="billChannel">
                                    <option value="all">请选择</option>
                                    <!--{foreach from=$global_array.bill_channel item=bill_channel_name key=bill_channel}-->
                                    <option value="<!--{$bill_channel}-->"><!--{$bill_channel_name}--></option>
                                    <!--{/foreach}-->
                                </select>
                            </td>
                            <td>订单类型：<select class="form-control input-sm" name="billType">
                                    <option value="all">请选择</option>
                                    <!--{foreach from=$global_array.bill_type item=bill_type_name key=bill_type}-->
                                    <option value="<!--{$bill_type}-->"><!--{$bill_type_name.name}--></option>
                                    <!--{/foreach}-->
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">下单日期：<input class="form-control input-sm w100" id="startDate" name="startDate" value="" readonly="readonly"   type="text" />
                                ～
                                <input class="form-control input-sm w100" id="endDate" name="endDate" value="" readonly="readonly" type="text" " />
                                <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear('startDate', 'endDate');">清 空</button>
                            </td>
                            <td>配送日期：<input class="form-control input-sm w85" id="send_date" name="send_date" value="" readonly="readonly" type="text" />
                                <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear('send_date');">清 空</button>
                            </td>
                            <td>城　　市：<select class="form-control input-sm" name="deliver_cityid" id="deliver_cityid">
                                    <option value="">请选择</option>
                                    <!--{if isset($city_array)}-->
                                        <!--{foreach from=$city_array item=city}-->
                                            <option value="<!--{$city.id}-->"><!--{$city.name}--></option>
                                        <!--{/foreach}-->
                                    <!--{/if}-->
                                </select>
                            </td>
                            <td>配 送 站：<select class="form-control input-sm" name="distribution_id" id="distribution_id">
                                    <option value="">请选择</option>
                                </select>
                            </td>

                        </tr>
                        <tr>
                            <td>下 单 人：<input type="text" class="form-control input-sm w120" name="creator" maxlength="20"></td>
                            <td>商　　品：<input type="text" class="form-control input-sm w120" name="goods_name_str" maxlength="20"></td>
                            <td colspan="2">
                                收货地址：<input type="text" class="form-control input-sm w120" style="width: 300px" id="deliver_address_str" name="deliver_address_str" maxlength="20">
                            </td>
                            <td>
                                <button type="button" class="btn btn-primary btn-sm" onclick="bill.search();">查 询</button>&nbsp;&nbsp;
                                <button type="button" class="btn btn-warning btn-sm" onclick="bill.clear();">重 置</button>&nbsp;&nbsp;
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
        <!-- 查询条件   end -->

        <table id="flex" style="display:none"></table>

    </div>

    

</div>




<script type="text/javascript">

    $("#flex").flexigrid({
        url:"/invokingAjax-backend/bill/billSearch.ajax?operFlg=3",
        dataType: "json",
        colModel : [
            {display: "操作", width : 150, align: "center"},
            {display: "订单编号", name : "bill_no", width : 230, sortable : true, align: "center"},
            {display: "订单类型", width : 100},
            {display: "订单状态", width : 80},
            {display: "订单标识", width : 80},
            {display: "支付方式", width : 120},
            {display: "配送时间", name : "send_date_time", width : 200,sortable : true},
            {display: "下单时间", width : 140, align: "center"},
            {display: "商品明细", width : 350},
            {display: "商品数量", width : 80},
            {display: "订单金额", width : 80},
            {display: "应收金额", width : 80},
            {display: "已收金额", width : 80},
            {display: "城市", width : 80},
            {display: "区", width : 80},
            {display: "配送站", width : 120},
            {display: "配送员", width : 120},
            {display: "配送员手机", width : 120},
            {display: "收货人手机号码", width : 120, align: "center"},
            {display: "收货人", width : 120},
            {display: "创建人", width : 120},
            {display: "退货状态", width : 100}
        ],
        sortname: "bill_no",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    /**
     * 订单操作类
     */
    var bill = {

        //查询
        search: function() {
            if($('#deliver_address_str').val().length < 4 && $('#deliver_address_str').val().length >0){
                E.alert('地址条件必须满4个字符');
                $('#deliver_address_str').select();
                $('#deliver_address_str').focus();
                return;
            }
            var dt = $("#search_form").serializeArray();
            $("#flex").flexOptions({newp: 1, params: dt}).flexReload();
        },

        //重置
        clear: function() {
            document.getElementById('search_form').reset();
            this.search();
        },

        //清空
        timeClear:function(){
            for(var i=0; i<arguments.length; i++){
                var id = arguments[i];
                $('#'+id).val('');
            }
        },

        //审核
        audit: function( bill_no ,remark) {
            this.bill_no = bill_no;
            E.confirm("您确认审核该订单吗？", "bill.confirmAudit");
        },


        confirmAudit: function() {
            E.ajax_get({
                url: "/invokingAjax-backend/bill/bill.ajax?operFlg=3",
                data: {
                    bill_no: this.bill_no
                },
                call: "bill.result"
            });
        },

        result: function( o ) {
            if (o.code == 200) {
                E.alert(o.message, 2);
                bill.search();
            } else {
                E.alert(o.message);
            }
        },

        //修改订单
        alter: function(bill_no) {
            window.open('/quanliadmin/app/bill/billEdit.pscript?operFlg=5&bill_no=' + bill_no);
        },

        //取消订单
        cancel: function( bill_no ) {
            this.bill_no = bill_no;
            E.confirm("您确认取消该订单吗？", "bill.confirmCancel");
        },

        confirmCancel: function() {
            E.ajax_get({
                url: "/invokingAjax-backend/bill/bill.ajax?operFlg=4",
                data: {
                    bill_no: this.bill_no
                },
                call: "bill.result"
            });
        },

        //退货
        returnGoods : function( bill_no ) {
            window.open("/quanliadmin/app/bill/billReturn.pscript?operFlg=2&bill_no=" + bill_no);
        },

        //刷新表格
        load: function() {
            $("#flex").flexReload();
        },

        //下车
        debus:function(bill_no){

            this.bill_no = bill_no;

            E.confirm("您确认执行打包操作吗？", "bill.excuteDebus");

        },

        excuteDebus:function(){

            E.loadding.open('正在打包中，请稍后...');
            E.ajax_post({
                url: '/invokingAjax-backend/bill/bill.ajax?operFlg=9',
                data: {
                    bill_no: this.bill_no
                },
                call:function(o){
                    E.loadding.close();
                    if(o.code == 200){
                        bill.load();
                        E.alert(o.message, 2, '');
                    }else{
                        E.alert(o.message);
                    }
                }
            });
        }

    };

    $('#startDate').datepicker();
    $('#endDate').datepicker();
    $('#send_date').datepicker();

    $(function() {

        //配送站根据城市改变联动
        $('#deliver_cityid').change(function() {
            var deliver_cityid = $(this).val();
            if (deliver_cityid == '') {
                $('#distribution_id').html('<option value="">请选择</option>');
            } else {
                E.ajax_get({
                    url: '/invokingAjax-comm/bill/distribution.ajax?operFlg=2',
                    data: {
                        deliver_cityid: deliver_cityid,
                        no_act: 1
                    },
                    call: function( o ) {
                        $('#distribution_id').html('<option value="">请选择</option>');
                        if (o.data) {
                            $.each(o.data, function(k, v) {
                                $('#distribution_id').append('<option value="' + v.distribution_id + '">' + v.distribution_name + '</option>');
                            });
                        }
                    }
                });
            }
        });

    });

</script>

</body>
</html>